package paperless.setting;

import java.util.List;

import android.app.Activity;
import android.app.Notification;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SettingAdapter extends BaseAdapter {

	int a = 0;
	List<MyData> mData;
	Context mContext;
	public final static int VIEW_TYPE_COUNT = 2;
	public final static int VIEW_TYPE_RECEIVE = 0;
	public final static int VIEW_TYPE_SEND = 1;

	OnAdapterItemClickListener mListener;

	public interface OnAdapterItemClickListener {
		public void onAdapterItemClick(String data);
	}

	public void setOnAdapterItemClickListener(
			OnAdapterItemClickListener listener) {
		mListener = listener;
	}

	public SettingAdapter(Context context, List<MyData> data) {
		mData = data;
		mContext = context;
	}

	@Override
	public int getCount() {
		return mData.size();
	}

	@Override
	public MyData getItem(int position) {
		return mData.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public int getViewTypeCount() {
		return VIEW_TYPE_COUNT;
	}

	@Override
	public int getItemViewType(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(mData.get(position).isCaption == true){
			BlueView bv;
			if(convertView == null){
				bv = new BlueView(mContext);
			} else{
				bv = (BlueView)convertView;
			}
			bv.setMyData(mData.get(position).txt);
			return bv;
		}else{
			WhiteView wv;
			if(convertView == null){
				wv = new WhiteView(mContext);
			} else{
				wv = (WhiteView)convertView;
			}
			wv.setMyData(mData.get(position).txt);
			return wv;
		}
	}
	
	public void add(String str, boolean isCaption) {
		mData.add(new MyData(str,isCaption));
		notifyDataSetChanged();
	}

}
